************************************************
***Title: robustness_specifications.do
***Creators: Joelle Abramowitz, Shooshan Danagoulian, and Owen Fleming*
***Notes: This file produces the estimates of the effect of pollen exposure on suicides using several alternate specifications. 

*For questions, contact
*Owen Fleming
*hg3490@wayne.edu
************************************************


**********SETUP
use data/for_analysis, clear

*Some additional variable creation
bysort county (date): gen pollen_1 = pollen[_n-1]

egen pollen_std =std(pollen), by(county season)
gen pollen_std_sq = pollen_std^2

bysort county (date): gen pollen_std_1 = pollen_std[_n-1]
bysort county (date): gen pollen_std_sq_1 = pollen_std_sq[_n-1]


**********PRODUCE ESTIMATES
*Treatment: log(pollen+1)
eststo rob_s1: ppmlhdfe count ln_pollen_plus1 $weather, absorb(county_season year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County x Season, Year x Month, Month x Day"

*Treatment: log(pollen+1), log(pollen+1) [t-1]
eststo rob_s2: ppmlhdfe count ln_pollen_plus1 ln_pollen_plus1_1 $weather, absorb(county_season year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County x Season, Year x Month, Month x Day"

*Treatment: pollen, pollen^2
eststo rob_s3: ppmlhdfe count pollen pollen_sq $weather, absorb(county_season year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County x Season, Year x Month, Month x Day"

*Treatment: pollen, pollen^2, pollen [t-1], pollen^2 [t-1]
eststo rob_s4: ppmlhdfe count pollen pollen_sq pollen_1 pollen_sq_1 $weather, absorb(county_season year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County x Season, Year x Month, Month x Day"

*Treatment: location-season quartiles with lag
eststo rob_s7: ppmlhdfe count pollen_q2_ls pollen_q3_ls pollen_q4_ls pollen_q2_ls_1 pollen_q3_ls_1 pollen_q4_ls_1 $weather, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Year x Month, Month x Day"

*Treatment: seasonal quartiles with lag
eststo rob_s8: ppmlhdfe count pollen_q2_s pollen_q3_s pollen_q4_s pollen_q2_s_1 pollen_q3_s_1 pollen_q4_s_1 $weather, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Year x Month, Month x Day"

*Treatment: location-season quartiles
eststo rob_s9: ppmlhdfe count pollen_q2_ls pollen_q3_ls pollen_q4_ls $weather pollen_ma, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather, 7-day moving average of pollen (not including current day)" 
estadd local FE "County, Year x Month, Month x Day"


**********EXPORT
estout using results/robustness_specifications.xls, cells(b(star label(Coef.) fmt(4)) se(par(`"="("'`")""') label(Std. Err.) fmt(4))) stats(ymean N counties Controls FE) starlevels(* 0.1 ** 0.05 *** 0.01) keep(ln_pollen_plus1 ln_pollen_plus1_1 pollen pollen_sq pollen_1 pollen_sq_1 pollen_q2_ls pollen_q3_ls pollen_q4_ls pollen_q2_ls_1 pollen_q3_ls_1 pollen_q4_ls_1 pollen_q2_s pollen_q3_s pollen_q4_s pollen_q2_s_1 pollen_q3_s_1 pollen_q4_s_1) legend label replace 
eststo clear


